package thread;

/**
 * 中断线程
 */
public class SleepDemo2 {
    public static void main(String[] args) {
        Thread wkj = new Thread("wkj"){
          public void run(){
              System.out.println(getName()+"睡一会");
              try {
                  Thread.sleep(1000000000);
              } catch (InterruptedException e) {
                  System.out.println("干嘛呢！干嘛呢！干嘛呢！");
              }
              System.out.println("都破了相了！");
          }
        };
        wkj.start();

        Thread hh  = new Thread("hh"){
            public void run(){
                for (int i=0;i<5;i++){
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(getName()+":八十！");

                }
                System.out.println(getName()+":大哥！搞定！");
                wkj.interrupt();//终端睡眠，触发InterruptedException异常
            }
        };
        hh.start();
    }
}
